package entities;

import gfx.Glyphs;
import gfx.Image;

import javax.microedition.khronos.opengles.GL10;

import android.graphics.PointF;
import util.GameVars;
import util.Logger;

public class Gate {
	short value;
	short row;
	short lane;
	short difficulty;
	boolean rightAnswer;
	boolean isSet;
	
	PointF drawLoc;
	
	public Gate(short difficulty, short answer, boolean isTrue, short lane, short row){
		rightAnswer = isTrue;
		this.lane = lane;
		this.row = row;
		this.difficulty = difficulty;
		
		drawLoc = new PointF(lane, (1 + row) * GameVars.ROW_DISTANCE[difficulty] + GameVars.GATE_START_MOD);

//		Logger.log("Designated[" + lane + "]");

//		if(isTrue)
			value = answer;
//		else value = generateAnswer(difficulty, answer, lower);
	}
	
//	public short generateAnswer(short difficulty, short answer, boolean lower){
//		switch(difficulty){
//		case GameVars.DIFFICULTY_EASY:
//			break;
//		case GameVars.DIFFICULTY_NORMAL:
//			break;
//		case GameVars.DIFFICULTY_HARD:
//			break;
//		case GameVars.DIFFICULTY_INSANE:
//			break;
//		default:
//			break;
//		}
//		return 0;
//	}
	
	// TODO Change the y draw to what it should be.
	public void draw(GL10 gl, Image img, boolean displayAnswers){
		img.draw(gl, drawLoc);
		if(displayAnswers)
			Glyphs.drawString(gl, Short.toString(value), drawLoc, GameVars.TEXT_ALIGNMENT_CENTER);
		else
			Glyphs.drawString(gl, "??", drawLoc, GameVars.TEXT_ALIGNMENT_CENTER);
	}

	public void setIsSet(boolean s){ isSet = s; }
	public boolean isSet(){ return isSet; }
	public void moveBack(){ row += 3; drawLoc.set(lane, (1 + row) * GameVars.ROW_DISTANCE[difficulty] + GameVars.GATE_START_MOD); }
	public void setValue(short v){ value = v; }
	public void setIsRight(boolean r){ rightAnswer = r; }
	public float getValue(){ return value; }
	public boolean isRight(){ return rightAnswer; }
}
